import layoutHeaderAside from '@/layout/header-aside'

// 由于懒加载页面太多的话会造成webpack热更新太慢，所以开发环境不使用懒加载，只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示
 */
const frameIn = [
  {
    path: '/',
    redirect: { name: 'index' },
    component: layoutHeaderAside,
    children: [
      // 首页
      {
        path: 'index',
        name: 'index',
        meta: {
          auth: true
        },
        component: _import('system/index')
      },
      /* 
      ------------------------------------   经销商路由   --------------------------------------------
      */
      {
        path: 'user/userInfo',
        name: 'user-userInfo',
        meta: {
          title: '修改密码',
          auth: true
        },
        component: _import('user/userInfo')
      },
      {
        path: 'user/dealerInfo',
        name: 'user-dealerInfo',
        meta: {
          title: '零售商信息',
          auth: true
        },
        component: _import('user/dealerInfo')
      },
      {
        path: 'goods/goodsInfo',
        name: 'goods-goodsInfo',
        meta: {
          title: '商品查询',
          auth: true
        },
        component: _import('goods/goodsInfo')
      },
      {
        path: 'goods/goodSort',
        name: 'goods-goodSort',
        meta: {
          title: '商品分类',
          auth: true
        },
        component: _import('goods/goodSort')
      },
      {
        path: 'goods/goodAdd',
        name: 'goods-goodAdd',
        meta: {
          title: '添加商品',
          auth: true
        },
        component: _import('goods/goodAdd')
      },
      {
        path: 'goods/stockManage',
        name: 'goods-stockManage',
        meta: {
          title: '库存管理',
          auth: true
        },
        component: _import('goods/stockManage')
      },
      {
        path: 'saleManage/orderQuery',
        name: 'saleManage-orderQuery',
        meta: {
          title: '销售订单查询',
          auth: true
        },
        component: _import('saleManage/orderQuery')
      },
      {
        path: 'saleManage/orderInfo',
        name: 'saleManage-orderInfo',
        meta: {
          title: '销售订单明细',
          auth: true
        },
        component: _import('saleManage/orderInfo')
      },
      {
        path: 'reportForm/storeByItem',
        name: 'reportForm-storeByItem',
        meta: {
          title: '销售报表',
          auth: true
        },
        component: _import('reportForm/storeByItem')
      },
      /* 
      ------------------------------------   厂商路由   --------------------------------------------
      */
      {
        path: 'userManufacturer/userInfoManufacturer',
        name: 'userManufacturer-userInfoManufacturer',
        meta: {
          title: '修改密码',
          auth: true
        },
        component: _import('userManufacturer/userInfoManufacturer')
      },
      {
        path: 'userManufacturer/dealerInfo',
        name: 'userManufacturer-dealerInfo',
        meta: {
          title: '经销商信息',
          auth: true
        },
        component: _import('userManufacturer/dealerInfo')
      },
      {
        path: 'goodsManufacturer/goodsInfoManufacturer',
        name: 'goodsManufacturer-goodsInfoManufacturer',
        meta: {
          title: '商品查询',
          auth: true
        },
        component: _import('goodsManufacturer/goodsInfoManufacturer')
      },
      {
        path: 'goodsManufacturer/goodSortManufacturer',
        name: 'goodsManufacturer-goodSortManufacturer',
        meta: {
          title: '商品分类',
          auth: true
        },
        component: _import('goodsManufacturer/goodSortManufacturer')
      },
      {
        path: 'goodsManufacturer/goodAddManufacturer',
        name: 'goodsManufacturer-goodAddManufacturer',
        meta: {
          title: '添加商品',
          auth: true
        },
        component: _import('goodsManufacturer/goodAddManufacturer')
      },
      {
        path: 'goodsManufacturer/stockManageManufacturer',
        name: 'goodsManufacturer-stockManageManufacturer',
        meta: {
          title: '库存管理',
          auth: true
        },
        component: _import('goodsManufacturer/stockManageManufacturer')
      },
      {
        path: 'goodsManufacturer/stockInfo',
        name: 'goodsManufacturer-stockInfo',
        meta: {
          title: '库存详情',
          auth: true
        },
        component: _import('goodsManufacturer/stockInfo')
      },
      {
        path: 'saleManageManufacturer/orderQueryManufacturer',
        name: 'saleManageManufacturer-orderQueryManufacturer',
        meta: {
          title: '销售订单查询',
          auth: true
        },
        component: _import('saleManageManufacturer/orderQueryManufacturer')
      },
      {
        path: 'saleManageManufacturer/orderManageInfo',
        name: 'saleManageManufacturer-orderManageInfo',
        meta: {
          title: '销售订单明细',
          auth: true
        },
        component: _import('saleManageManufacturer/orderManageInfo')
      },
      {
        path: 'reportFormManufacturer/storeByItemManufacturer',
        name: 'reportFormManufacturer-storeByItemManufacturer',
        meta: {
          title: '销售报表',
          auth: true
        },
        component: _import('reportFormManufacturer/storeByItemManufacturer')
      },
      /* 
      ------------------------------------   admin 路由   --------------------------------------------
      */
      {
        path: 'accountAdmin/accounts',
        name: 'accountAdmin-accounts',
        meta: {
          title: '账号管理',
          auth: true,
        },
        component: _import('accountAdmin/accounts')
      },
      {
        path: 'accountAdmin/accountInfo',
        name: 'accountAdmin-accountInfo',
        meta: {
          title: '账号详情',
          auth: true,
        },
        component: _import('accountAdmin/accountInfo')
      },
      {
        path: 'accountAdmin/config',
        name: 'accountAdmin-config',
        meta: {
          title: '配置特定页面',
          auth: true,
        },
        component: _import('accountAdmin/config')
      },
      {
        path: 'accountAdmin/goodTypes',
        name: 'accountAdmin-goodTypes',
        meta: {
          title: '配置物品种类',
          auth: true,
        },
        component: _import('accountAdmin/goodTypes')
      },
      {
        path: 'accountAdmin/order',
        name: 'accountAdmin-order',
        meta: {
          title: '订单管理',
          auth: true,
        },
        component: _import('accountAdmin/order')
      },
      {
        path: 'accountAdmin/orderInfo',
        name: 'accountAdmin-orderInfo',
        meta: {
          title: '订单明细',
          auth: true,
        },
        component: _import('accountAdmin/orderInfo')
      },
      // 系统 前端日志
      {
        path: 'log',
        name: 'log',
        meta: {
          title: '前端日志',
          auth: true
        },
        component: _import('system/log')
      },
      // 刷新页面 必须保留
      {
        path: 'refresh',
        name: 'refresh',
        hidden: true,
        component: _import('system/function/refresh')
      },
      // 页面重定向 必须保留
      {
        path: 'redirect/:route*',
        name: 'redirect',
        hidden: true,
        component: _import('system/function/redirect')
      }
    ]
  }
]

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    meta: {
      manage: 'admin'
    },
    component: _import('system/login')
  }
]

/**
 * 错误页面
 */
const errorPage = [
  {
    path: '*',
    name: '404',
    component: _import('system/error/404')
  }
]

// 导出需要显示菜单的
export const frameInRoutes = frameIn

// 重新组织后导出
export default [
  ...frameIn,
  ...frameOut,
  ...errorPage
]
